package com.eos.control.action.emp;

import com.eos.business.service.SysUserBusinessService;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysUser;
import com.hf.utils.MD5Util;

public class ResetEmpPwdAction extends AbstractBaseAction {
	private static final long serialVersionUID = -2918226612187537805L;
	private Integer sysUserId;
	
	public void setSysUserId(Integer sysUserId) {
		this.sysUserId = sysUserId;
	}

	@Override
	public String execute() {
		try {
			if(null == sysUserId || sysUserId.intValue() == 0){
				statusCode = "300";
				message = "参数错误, 密码重置失败!";
			}else{
				SysUser user = new SysUser();
				user.setId(sysUserId);
				user.setPassWord(new MD5Util().encrypt("123456"));
				SysUserBusinessService sbs = new SysUserBusinessService();
				String flag = sbs.update(user);
				if("SUCCESS".equals(flag)){
					statusCode = "200";
					message = "密码重置成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 密码重置出错!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常,密码重置出错!";
		}
		return SUCCESS;
	}
}
